package it.mauriziobasile.andoid.aub.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;

@Root(name = "hosts")
public class Hosts implements Serializable {

    private static final long serialVersionUID = -8630979812566548823L;

    @Root(name = "host")
    public static class Host implements Serializable {
        private static final long serialVersionUID = -7006481450383151025L;

        @Attribute(name = "name", required = true, empty = "localhost")
        private String name;

        @Attribute(name = "ip", required = true, empty = "127.0.0.1")
        private String ip;

        public String getIp() {
            return ip;
        }

        public void setIp(String ip) {
            this.ip = ip;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }
    }

    @Root(name = "meta")
    public static class Meta implements Serializable {
        private static final long serialVersionUID = 3172631397402829107L;
        @Element(name = "author", data = false, required = false, type = String.class)
        private String author;
        @Element(name = "version", data = false, required = false, type = Integer.class)
        private int version;
        @Element(name = "date", data = false, required = false, type = Date.class)
        private Date date;

        public String getAuthor() {
            return author;
        }

        public void setAuthor(String author) {
            this.author = author;
        }

        public int getVersion() {
            return version;
        }

        public void setVersion(int version) {
            this.version = version;
        }

        public Date getDate() {
            return date;
        }

        public void setDate(Date date) {
            this.date = date;
        }

    }

    @Element(name = "meta", required = false, type = Meta.class)
    private Meta meta;

    @ElementList(inline = true)
    private List<Host> hosts;

    public Meta getMeta() {
        return meta;
    }

    public void setMeta(Meta meta) {
        this.meta = meta;
    }

    public List<Host> getHosts() {
        return hosts;
    }

    public void setHosts(List<Host> hosts) {
        this.hosts = hosts;
    }
}
